package lab2.demo;

import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import lab2.demo.NoticeEvent;

@Component
public class CNoticeListener implements ApplicationListener<NoticeEvent> {

    @Override
    public void onApplicationEvent(NoticeEvent noticeEvent)
    {
        System.out.println("事件监听器获取到NoticeEvent,睡眠当前线程2秒..");
        try{
            Thread.sleep(2000);
        }catch (InterruptedException e){
            e.printStackTrace();
        }
        System.out.println("NoticeEvent的message属性是：" .concat(noticeEvent.getMessage()));
    }
}
